package com.yungu.swift.schedule.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.order.service.OrderJoinService;
import com.yungu.swift.order.service.OrderService;
import com.yungu.swift.order.service.RefundService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import static com.yungu.swift.schedule.config.NacosListener.SYS_CONFIG;

@Service
public class JoinOrderService {

    private static final Logger logger = LoggerFactory.getLogger(JoinOrderService.class);

    @Reference
    private RefundService refundService;
    @Reference
    private OrderJoinService orderJoinService;

    /**
     * 30分钟执行一次
     *
     * @throws Exception
     */
    public void refund() {
        logger.info("（跨城）触发退款查询定时任务");
        refundService.refundQuery(null, "SYSTEM");
    }

    /**
     * 1分钟执行一次
     */
    public void closeOrder() {
        logger.info("（跨城）触发订单超时关闭定时任务");
        orderJoinService.closeJoinOrder(SYS_CONFIG.getAppid());
    }

    /**
     * 1分钟执行一次
     */
    public void deparOrderPushMsg() {
        logger.info("（跨城）触发订单出发前消息推送定时任务");
        orderJoinService.deparOrderPushMsg(SYS_CONFIG.getAppid());
    }
}
